package com.qo.qsdk;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;

import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.qo.qsdk.config.QSDKLanguage;
import com.qo.qsdk.listener.CustomerResultListener;
import com.qo.qsdk.listener.ExitResultListener;
import com.qo.qsdk.listener.FacebookLikeResultListener;
import com.qo.qsdk.listener.GuestBindResultListener;
import com.qo.qsdk.listener.HistoryResultListener;
import com.qo.qsdk.listener.InitResultListener;
import com.qo.qsdk.listener.LoginResultListener;
import com.qo.qsdk.listener.LogoutResultListener;
import com.qo.qsdk.listener.PayResultListener;
import com.qo.qsdk.listener.ReviewResultListener;
import com.qo.qsdk.listener.SubmitRoleResultListener;
import com.qo.qsdk.listener.SwitchAccountResultListener;
import com.qo.qsdk.listener.SwitchLanguageListener;
import com.qo.qsdk.model.SDKInfoModel;
import com.qo.qsdk.param.GameRoleParams;
import com.qo.qsdk.param.PayParams;
import com.qo.qsdk.ui.AccountActivity;
import com.qo.qsdk.ui.ExitActivity;
import com.qo.qsdk.ui.HisActivity;
import com.qo.qsdk.utils.QSDKHelper;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

public class QSDKApi {

    private static final String TAG = QSDKApi.class.getSimpleName();
    private volatile static QSDKApi INSTANCE;

    public static QSDKApi getInstance() {
        if (INSTANCE == null) {
            synchronized (QSDKApi.class) {
                if (INSTANCE == null) {
                    INSTANCE = new QSDKApi();
                }
            }
        }
        return INSTANCE;
    }

    public void init(Activity activity, InitResultListener initResultListener) {
        QSDK.getInstance().init(activity, initResultListener);
    }

    public void login(Activity activity, LoginResultListener loginResultListener) {
        QSDK.getInstance().login(activity, loginResultListener);
    }

    public void logout(Activity activity, LogoutResultListener logoutResultListener) {
        QSDK.getInstance().logout(activity, logoutResultListener);
    }

    public void switchAccount(Activity activity, SwitchAccountResultListener switchAccountResultListener) {
        QSDK.getInstance().switchAccount(activity, switchAccountResultListener);
    }

    public void pay(Activity activity, PayParams payParams, PayResultListener payResultListener) {
        QSDK.getInstance().pay(activity, payParams, payResultListener);
    }

    private SubmitRoleResultListener mSubmitRoleResultListener;
    public void submitGameRoleInfo(Activity activity, GameRoleParams gameRoleParams, SubmitRoleResultListener submitRoleResultListener) {
        QSDK.getInstance().submitGameRoleInfo(activity, gameRoleParams, submitRoleResultListener);
    }

    public void exitGame(Activity activity, ExitResultListener exitResultListener) {
        QSDK.getInstance().exitGame(activity, exitResultListener);
    }

    public void showHistoryAccount(Activity activity, HistoryResultListener historyResultListener) {
        QSDK.getInstance().showHistoryAccount(activity, historyResultListener);
    }

    public void showReview(Activity activity, ReviewResultListener reviewResultListener) {
        QSDK.getInstance().showReview(activity, reviewResultListener);
    }

    public void showService(Activity activity, CustomerResultListener customerResultListener) {
        QSDK.getInstance().showService(activity, customerResultListener);
    }

    public void showLike(Activity activity, FacebookLikeResultListener facebookLikeResultListener) {
        QSDK.getInstance().showLike(activity, facebookLikeResultListener);
    }

    public void showBind(Activity activity, GuestBindResultListener guestBindResultListener) {
        QSDK.getInstance().showBind(activity, guestBindResultListener);
    }

    public void showAssistor(Activity activity) {
        QSDK.getInstance().showAssistor(activity);
    }

    public void hideAssistor(Activity activity) {
        QSDK.getInstance().hideAssistor(activity);
    }

    public void switchLanguage(Activity activity, QSDKLanguage language, SwitchLanguageListener languageListener) {
        QSDK.getInstance().switchLanguage(activity, language, languageListener);
    }

    public void onCreate(Activity activity, Bundle savedInstanceState) {
        QSDK.getInstance().onCreate(activity, savedInstanceState);
    }

    public void onStart(Activity activity) {
        QSDK.getInstance().onStart(activity);
    }

    public void onResume(Activity activity) {
        QSDK.getInstance().onResume(activity);
    }

    public void onPause(Activity activity) {
        QSDK.getInstance().onPause(activity);
    }

    public void onStop(Activity activity) {
        QSDK.getInstance().onStop(activity);
    }

    public void onRestart(Activity activity) {
        QSDK.getInstance().onRestart(activity);
    }

    public void onNewIntent(Activity activity, Intent intent) {
        QSDK.getInstance().onNewIntent(activity, intent);
    }

    public void onKeyDown(Activity activity, int keyCode, KeyEvent event) {
        QSDK.getInstance().onKeyDown(activity, keyCode, event);
    }

    public void onBackPressed(Activity activity) {
        QSDK.getInstance().onBackPressed(activity);
    }

    public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
        QSDK.getInstance().onActivityResult(activity, requestCode, resultCode, data);
    }

    public void onDestroy(Activity activity) {
        QSDK.getInstance().onDestroy(activity);
    }

    public void onConfigurationChanged(Activity activity, Configuration newConfig) {
        QSDK.getInstance().onConfigurationChanged(activity, newConfig);
    }

    public void onRequestPermissionsResult(Activity activity, int requestCode,
                                                  String[] permissions,
                                                  int[] grantResults) {

    }

}
